package com.example.demo.common.constant;

import lombok.Getter;

@Getter
public enum ResultCode {
    /* 成功 */
    SUCCESS(1, "成功"),

    /* 警告 */
    WARN(0, "警告"),

    /* 参数校验异常：1001~1999 */
    PARAM_IS_NULL(1001, "参数为null"),
    PARAM_IS_BLANK(1002, "参数为空"),
    PARAM_TYPE_ERROR(1003, "参数类型错误"),
    PARAM_DELETION(1004, "参数缺失"),
    PARAM_FORMAT_ERROR(1005, "参数格式错误"),
    PARAM_SPECIAL_CHAR(1006, "参数有特殊字符"),
    PARAM_CONVERT_ERROR(1007, "参数对象转换错误"),
    PARAM_XSS_ATTACK(1008, "参数XSS与SQL注入攻击"),
    PARAM_RANGE_ERROR(1009, "参数大小超出范围"),
    PARAM_RSA_ERROR(1010, "参数RSA解密错误"),
    FILE_IS_NULL(1021, "文件为空"),
    FILE_FORMAT_ERROR(1022, "文件格式错误"),
    FILE_SIZE_EXCEED(1023, "文件大小超出范围"),
    FILE_CONVERT_ERROR(1024, "文件对象转换错误"),
    JWT_CHECK_ERROR(1101, "jwt签名验证错误"),
    VALID_ERROR_FLAG(1999, "参数校验类异常标志"),

    /* 身份验证异常：2001~2999 */
    USER_REDIS_INIT_ERROR(2001, "redis初始化异常"),
    USER_TOKEN_WEB_DELETION(2002, "token前端未传参"),
    USER_TOKEN_LENGTH_ERROR(2003, "token长度错误"),
    USER_TOKEN_CONTENT_EMPTY(2004, "token至少一项为空"),
    USER_TOKEN_CONTENT_ERROR(2005, "token至少一项错误"),
    USER_TOKEN_REDIS_DELETION(2006, "过期了请重新登录"),
    USER_TOKEN_RANDOM_ERROR(2007, "用户已在别处登录"),
    USER_TOKEN_TIMEOUT(2008, "token长时间失效"),
    USER_TOKEN_EXPIRE(2009, "token重新设置有效期"),
    USER_IDENTITY_ERROR(2010, "用户无权访问"),
    USER_NOTIN_WHITELIST(2098, "用户不在白名单内"),
    USER_IP_PROHIBIT(2099, "用户IP被禁止访问"),
    USER_IP_LIMITOUT(2100, "用户IP超出访问次数"),
    PROHIBIT_ID_IS_NULL(2101, "防重ID为空"),
    PROHIBIT_REPEAT(2102, "不能重复提交"),
    VISIT_ERROR_FLAG(2999, "身份验证类异常标志"),

    /* 数据异常：3001~3999 */
    DATA_NOT_EXIST(3001, "信息不存在"),
    DATA_EXPIRE(3002, "信息过期"),
    DATA_NOT_ONLY(3003, "信息不唯一"),
    SIGN_EXPIRE(3004, "签名已过期"),
    SIGN_USED(3005, "签名已被使用"),
    SIGN_ERROR(3006, "签名错误"),
    DATA_ERROR_FLAG(3999, "数据类异常标志"),

    /* 业务逻辑异常：4001~4999 */
    REQUEST_REPEAT(4001, "访问太频繁，请稍候"),
    REQUEST_ANNOTATE_ERROR(4002, "缺少防重复注解的前缀名"),
    PACKAGE_RESULT_ERROR(4003, "封装返回值异常"),
    HTTP_POST_ERROR(4004, "发送Post请求异常"),
    HTTP_GET_ERROR(4005, "发送Get请求异常"),
    HTTP_CLOSE_ERROR(4006, "关闭Http连接异常"),
    LOGIN_USER_NOT_EXIST(4007, "用户未注册"),
    LOGIN_PASSWORD_ERROR(4008, "密码错误"),
    LOGIN_PASSWORD_FORMAT_ERROR(4009, "密码原始格式错误"),
    LOGIN_USER_ROLE_EMPTY(4010, "用户权限未设置"),
    LOGIN_USER_UPDATE_FAIL(4011, "用户信息更新失败"),
    IDEMPOTENT_KEY_EMPTY(4012, "幂等性key不能为空"),
    IDEMPOTENT_VALUE_EMPTY(4013, "幂等性value不能为空"),
    IDEMPOTENT_REPEAT_SUBMIT(4014, "服务正在处理，请勿重复提交"),
    BASE64_CONVERT_FILE_ERROR(4015, "Base64转换file失败"),
    BASE64_CONVERT_PIC_ERROR(4016, "Base64转换pic失败"),
    TEMPLATE_CONVERT_WORD_ERROR(4017, "模板生成Word失败"),
    BUSINESS_ERROR_FLAG(4999, "业务逻辑类异常标志"),

    /* 系统异常：9001~9999 */
    SYSTEM_INTERCEPT_ERROR(9001, "拦截器异常"),
    SYSTEM_RUNTIME_ERROR(9997, "运行时异常"),
    SYSTEM_OTHER_ERROR(9998, "未知异常"),
    SYSTEM_ERROR_FLAG(9999, "系统类异常标志");

    private final Integer code;
    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
